# Maintainer: Konstantin Podsvirov <konstantin@podsvirov.pro>

_realname=asio
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.18.1
pkgrel=1
pkgdesc='Cross-platform C++ library for ASynchronous network I/O (mingw-w64)'
url='https://think-async.com/Asio/'
arch=('any')
license=('custom:boost')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             #"${MINGW_PACKAGE_PREFIX}-boost"
             "${MINGW_PACKAGE_PREFIX}-openssl")
_realver=${pkgver//./-}
_realpath=${_realname}-${_realname}-${_realver}
source=("${_realpath}.tar.gz::https://github.com/chriskohlhoff/${_realname}/archive/${_realname}-${_realver}.tar.gz")
sha256sums=('39c721b987b7a0d2fe2aee64310bd128cd8cc10f43481604d18cb2d8b342fd40')

prepare() {
  cd ${srcdir}/${_realpath}/${_realname}/

  autoreconf -fiv
}

build() {
  cd ${srcdir}/${_realpath}/${_realname}/

  ./configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --with-boost=no \
    --with-openssl=yes

  make
}

check() {
  cd ${srcdir}/${_realpath}/${_realname}/
  make check
}

package() {
  cd ${srcdir}/${_realpath}/${_realname}/
  make DESTDIR=${pkgdir} install

  install -Dm 644 COPYING LICENSE_1_0.txt -t "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}"
}
